//
//  MNDFinanceTableViewCell.m
//  miniwangdai2
//
//  Created by 谭伟 on 2017/3/28.
//  Copyright © 2017年 谭谭伟. All rights reserved.
//
#pragma mark -投资列表cell

#import "MNDFinanceTableViewCell.h"
#import "ZZCircleProgress.h"
#import "MNDFinanceDetailViewController.h"

@implementation MNDFinanceTableViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    [self setupUI];
    
}

#pragma mark -搭建界面

- (void)setupUI {
    ZZCircleProgress *progressView = [[ZZCircleProgress alloc]initWithFrame:CGRectMake(0, 0, 50, 50) pathBackColor:[UIColor colorWithRed:220/255.0 green:220/255.0 blue:220/255.0 alpha:1.0] pathFillColor:[UIColor colorWithRed:78/255.0 green:140/255.0 blue:238/255.0 alpha:1.0] startAngle:0 strokeWidth:1];
    progressView.startAngle = -90;
    progressView.showPoint = NO;
    progressView.animationModel = CircleIncreaseSameTime;
//    progressView.progress = 0.6;
    [self.progressView addSubview:progressView];
    self.circleView = progressView;
    self.goInvestBtn.layer.cornerRadius = self.goInvestBtn.bounds.size.height*0.5;
    self.goInvestBtn.clipsToBounds = YES;
    
    self.creditorBtn.layer.cornerRadius = 3;
}


- (void)setCreditorsModel:(MNDCreditorsModel *)creditorsModel {
    _creditorsModel = creditorsModel;
    [self configContents];
}

- (void)setFinanceModel:(MNDFinanceDateModel *)financeModel {
    _financeModel = financeModel;
    [self configFinanceContents];
}
- (void)configContents{
    self.titleLabel.text = self.creditorsModel.title;
    self.moneyLabel.text = [NSString stringWithFormat:@"剩余%@元", self.creditorsModel.remainingable_tender ];
    self.yearAprLabel.text = self.creditorsModel.year_apr;
    self.circleView.progress = self.creditorsModel.nowProgress * 0.01;
    self.deadlineLabel.text = self.creditorsModel.deadline;
//    self.statusLabel.text = self.creditorsModel.txt_status;
    if ([self.creditorsModel.txt_status isEqualToString:@"已撤销"]) {
        self.statusImgV.hidden = NO;
        self.statusImgV.image = [UIImage imageNamed:@"creditor_cancel"];
        [self setGrayColorForView];
        [self.creditorBtn setBackgroundColor:kColorGray];
          self.moneyLabel.text = [NSString stringWithFormat:@"项目总额%@元", self.creditorsModel.principal];
    }else if([self.creditorsModel.txt_status isEqualToString:@"转让中"] || [self.creditorsModel.txt_status isEqualToString:@"进行中"]){
        self.statusImgV.hidden = YES;
        [self setBlackColorForView];
        [self.creditorBtn setBackgroundColor:kColorBlue];
    }else {//已完成
        [self setGrayColorForView];
        self.statusImgV.hidden = NO;
        self.statusImgV.image = [UIImage imageNamed:@"criditor_finish"];
        [self.creditorBtn setBackgroundColor:kColorGray];
         self.moneyLabel.text = [NSString stringWithFormat:@"项目总额%@元", self.creditorsModel.principal];
    }

    //显示债转标识
    self.creditorBtn.hidden = NO;
    [self.beginTimeLabel setHidden:YES];
    [self.beginLabel setHidden:YES];

}

- (void)configFinanceContents {

    self.titleLabel.text = self.financeModel.title;
    self.moneyLabel.text = [NSString stringWithFormat:@"剩余%@元", self.financeModel.remainingable_tender ];
    self.yearAprLabel.text = self.financeModel.year_apr;
    self.circleView.progress = self.financeModel.nowProgress * 0.01;
    self.deadlineLabel.text = self.financeModel.deadline;
//    self.statusLabel.text = self.financeModel.txt_status;
    if ([self.financeModel.txt_status isEqualToString:@"预热中"]) {
        self.moneyLabel.text = [NSString stringWithFormat:@"项目总额%@元", self.financeModel.money];
        self.statusImgV.hidden = NO;
        self.statusImgV.image = [UIImage imageNamed:@"preheat_status_img"];
        [self setBlackColorForView];
        [self.beginTimeLabel setHidden:NO];
        [self.beginLabel setHidden:NO];
        self.beginTimeLabel.text = self.financeModel.borrow_raise_start_time;
    }else if([self.financeModel.txt_status isEqualToString:@"进行中"]){
        self.statusImgV.hidden = YES;
        [self setBlackColorForView];
        [self.beginTimeLabel setHidden:YES];
        [self.beginLabel setHidden:YES];
    }else {
        self.statusImgV.hidden = NO;
        self.statusImgV.image = [UIImage imageNamed:@"finish_status_img"];
        [self setGrayColorForView];
         self.moneyLabel.text = [NSString stringWithFormat:@"项目总额%@元", self.financeModel.money];
        [self.beginTimeLabel setHidden:YES];
        [self.beginLabel setHidden:YES];
    }
    //隐藏债转标识
    self.creditorBtn.hidden = YES;
}


- (void)setBlackColorForView {
    self.titleLabel.textColor = kColorBlack;
    self.yearAprLabel.textColor = kColorOrange;
    //        self.circleView
    self.deadlineLabel.textColor = kColorBlack;
    self.monthDescLabel.textColor = kColorBlack;
    self.precentLabel.textColor = kColorOrange;
}
- (void)setGrayColorForView {
    self.titleLabel.textColor = kColorGray;
    self.yearAprLabel.textColor = kColorGray;
    //        self.circleView
    self.deadlineLabel.textColor = kColorGray;
    self.monthDescLabel.textColor = kColorGray;
    self.precentLabel.textColor = kColorGray;
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    
}

@end
